package com.cy.pj.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cy.pj.common.vo.JsonResult;
import com.cy.pj.common.vo.PageResult;
import com.cy.pj.sys.entity.SysMember;
import com.cy.pj.sys.entity.SysOrder;
import com.cy.pj.sys.service.SysMemberService;
import com.cy.pj.sys.service.SysOrderService;

@RestController
@RequestMapping("order/")
public class SysOrderController {


	@Autowired 
	private SysOrderService sysOrderService;
	
	/**
	 * 基于用户订单id删除订单
	 */
	@RequestMapping("doDeleteById") 
	public JsonResult doDeleteById(Integer id){
		sysOrderService.deleteOrderById(id); 
				
		return new JsonResult("删除成功！");
	}

	/**
	 * 基于订单id查询订单信息
	 */
	@RequestMapping("doFindOrderById") 
	public JsonResult doFindOrderById(Integer id){
		SysOrder list= 
				sysOrderService.findOrderById(id); 
		return new JsonResult(list);
	}

	/**
	 * 分页查询所有订单信息
	 */
	@RequestMapping("doFindPageObjects") 
	public JsonResult doFindPageObjects(String memberName,Integer pageCurrent){
		PageResult<SysOrder> list= 
				sysOrderService.findPageObjects(memberName,pageCurrent); 
		return new JsonResult(list);
	}

	/**
	 * 保存订单信息
	 */
	@RequestMapping("doSaveObject") 
	public JsonResult doSaveObject(SysOrder sysOrder){
		sysOrderService.saveOrderInfo(sysOrder); 
		return new JsonResult("订单提交成功!");

	}

	/**
	 * 基于会员手机号码进行支付
	 */
	@RequestMapping("doPayOrderById")
	@ResponseBody
	public JsonResult doPayOrderById(Long itemPrice, Integer id,String memberMobile){ 
		sysOrderService.payOrderById(itemPrice, id, memberMobile);
		return new JsonResult("支付成功");
	}

}







